﻿using System;

namespace AutoUpPrj
{
    class Program
    {
      
        static void Main(string[] args)
        {
            string prjname =System.Configuration.ConfigurationSettings.AppSettings["Prjname"];
            string mainexe = System.Configuration.ConfigurationSettings.AppSettings["mainexe"];
            string ip = System.Configuration.ConfigurationSettings.AppSettings["ip"];
            string port = System.Configuration.ConfigurationSettings.AppSettings["prot"];
            PrjAutoUp prjup = new PrjAutoUp();
            int creversion = 0;
            try
            {
                System.IO.StreamReader sr = new System.IO.StreamReader("version.bin");
                creversion=Convert.ToInt32( sr.ReadLine());
                sr.Close();
            }
            catch { }
           int maxvier= prjup.startUpdate(prjname, creversion, ip, Convert.ToInt32(port));
            try
            {
                System.IO.StreamWriter sr = new System.IO.StreamWriter("version.bin");
                sr.WriteLine(maxvier);
                sr.Close();
            }
            catch { }
            try
            {
                System.Diagnostics.Process.Start(mainexe);
            }
            catch (Exception e){

                Console.WriteLine(e.Message);
                Console.ReadKey();
            }


        }
    }
}
